/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package simpledraw;

import java.awt.Graphics;
import java.awt.Point;
import java.awt.Polygon;
import java.util.Iterator;

/**
 *
 * @author renatocardoso
 */
public class PolygonShape extends Shapes
{
  public void draw(Graphics g)
  {
    Point point = null;
    Iterator it = getList().iterator();
    //if the list does not contain the required two points, return.
    if(getList().size() < 3)
    {
      return;
    }
    Polygon p = new Polygon();
    for(;it.hasNext();)
    {
      point = (Point)it.next();
      p.addPoint((int)point.getX(), (int)point.getY());
    }
    g.drawPolygon(p);
    getList().clear();
  }//end of draw for Polygon
}//Polygon
